package com.bgds.sys.api.project;

import com.bgds.sys.api.project.service.DictService;
import com.bgds.sys.common.pagevo.Result;
import com.bgds.sys.common.utils.ResultUtil;
import com.bgds.sys.module.entity.project.DictItem;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 字典管理
 *
 * @author chenchao
 * @date 2021/9/14
 */
@RestController
@RequestMapping("/dict")
public class DictController {

    @Resource
    private DictService dictService;


    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") String id) {
        dictService.deleteDictItem(id);
        return new ResultUtil().success();
    }


    @GetMapping
    public Result list(String code) {
        return new ResultUtil().setData(dictService.dictItemList(code));
    }

    @PostMapping
    public Result save(@RequestBody DictItem dictItem) {
        dictService.saveDictItem(dictItem);
        return new ResultUtil().success();
    }

    @PutMapping
    public Result add(@RequestBody DictItem dictItem) {
        dictService.addDictItem(dictItem);
        return new ResultUtil().success();
    }

}
